package application.factory;

import application.adapter.TreeAdapter;
import lombok.SneakyThrows;

public class TreeEntryFactory {

    public static class Builder<T extends TreeAdapter.TreeEntry> {

        private TreeAdapter.TreeEntry treeEntry;

        @SneakyThrows
        public Builder(Class<T> clazz) {
            treeEntry = clazz.newInstance();
        }

        public Builder<T> setIsRoot(boolean isRoot) {
            this.treeEntry.setRoot(isRoot);
            return this;
        }

        public Builder<T> setFlag(String flag) {
            this.treeEntry.setFlag(flag);
            return this;
        }

        public Builder<T> setParentFlag(String parentFlag) {
            this.treeEntry.setParentFlag(parentFlag);
            return this;
        }

        public T builder() {
            return (T) this.treeEntry;
        }
    }
}
